//
//  BGRecordCell.swift
//  Billing
//
//  Created by Dale on 17/4/24.
//  Copyright © 2017年 Nari. All rights reserved.
//

import UIKit

typealias ModifyClosure = () -> Void

class BGRecordCell: UITableViewCell {

    @IBOutlet weak var dateLB: UILabel!
    @IBOutlet weak var typeLB: UILabel!
    @IBOutlet weak var timeLB: UILabel!
    @IBOutlet weak var moneyLB: UILabel!
    @IBOutlet weak var modifyBtn: UIButton!
    var modifyClosure: ModifyClosure!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.selectionStyle = .none
        modifyBtn.layer.cornerRadius = 4.0
        modifyBtn.layer.masksToBounds = true
    }

    class func cellWithTableView(tableView: UITableView) -> BGRecordCell {
        let cellIdentifier = "BGRecordCell"
        var cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as? BGRecordCell
        if cell == nil {
           cell = Bundle.main.loadNibNamed("BGRecordCell", owner: nil, options: nil)?[0] as? BGRecordCell
        }
        return cell!
    }
    
    func configureCell(model: Rocord) -> Void {
        dateLB.text = model.dateStamp
        timeLB.text = model.timeStamp
        moneyLB.text = model.money
        
        switch model.type {
        case "0"?:
            typeLB.text = "早上"
        case "1"?:
            typeLB.text = "中午"
        case "2"?:
            typeLB.text = "晚上"
        default:
            typeLB.text = "其它"
        }
    }
    @IBAction func handleModifyBtnAction(_ sender: Any) {
        self.modifyClosure?()
    }
    
}
